﻿using System;
using System.Collections.Generic;
using System.Text;
using Component;
using DevExpress.Xpo;

namespace Component
{
    public class ProductImgDB : Base
    {
        public static Component.ProductImg GetObjectByid(int id, bool admin)
        {
            XPCollection<ProductImg> _xpProductImg = new XPCollection<ProductImg>(KetNoiCSDL.session);
            _xpProductImg.Filter = FilterAll(admin);
            return _xpProductImg.Lookup(id);
        }

        public static XPCollection<ProductImg> GetAllObjByIdProduct(int idProduct)
        {
            XPCollection<ProductImg> _xpProductImg = new XPCollection<ProductImg>(KetNoiCSDL.session);
            _xpProductImg.Filter = FilterParamTypeInt(ColumProductImg._Product, idProduct, true);
            return _xpProductImg;
        }
        public static bool TestExistFile(string path,string colum)
        {
            XPCollection<ProductImg> _xpProductImg = new XPCollection<ProductImg>(KetNoiCSDL.session);
            _xpProductImg.Filter = FilterByString(colum, path, true);
            if (_xpProductImg.Count > 0)
            {
                return true;
            }
            return false;
        }
    }
}
